<div class="options">
  <a
    mat-raised-button
    href="https://github.com/tiberiuzuld/angular-gridster2/tree/master/src/app/sections/home"
    target="_blank"
    class="source-code-button"
  >
    <mat-icon>open_in_new</mat-icon>
    Source
  </a>
</div>
<div class="options-header">
  <mat-form-field>
    <mat-label>Grid Type</mat-label>
    <mat-select aria-label="Grid type" [(ngModel)]="options.gridType" (ngModelChange)="changedOptions()">
      <mat-option value="fit">Fit to screen</mat-option>
      <mat-option value="scrollVertical">Scroll Vertical</mat-option>
      <mat-option value="scrollHorizontal">Scroll Horizontal</mat-option>
      <mat-option value="fixed">Fixed</mat-option>
      <mat-option value="verticalFixed">Vertical Fixed</mat-option>
      <mat-option value="horizontalFixed">Horizontal Fixed</mat-option>
    </mat-select>
  </mat-form-field>
  <mat-form-field>
    <mat-label>Display grid lines</mat-label>
    <mat-select aria-label="Display grid lines" [(ngModel)]="options.displayGrid" (ngModelChange)="changedOptions()">
      <mat-option value="always">Always</mat-option>
      <mat-option value="onDrag&Resize">On Drag & Resize</mat-option>
      <mat-option value="none">None</mat-option>
    </mat-select>
  </mat-form-field>

  <mat-checkbox [(ngModel)]="options.swap" (ngModelChange)="changedOptions()"> Swap Items </mat-checkbox>
  <mat-checkbox [(ngModel)]="options.pushItems" (ngModelChange)="changedOptions()"> Push Items </mat-checkbox>
  @if (options.draggable) {
    <mat-checkbox [(ngModel)]="options.draggable.enabled" (ngModelChange)="changedOptions()"> Drag Items </mat-checkbox>
  }
  @if (options.resizable) {
    <mat-checkbox [(ngModel)]="options.resizable.enabled" (ngModelChange)="changedOptions()"> Resize Items </mat-checkbox>
  }
  <mat-checkbox [(ngModel)]="options.pushResizeItems" (ngModelChange)="changedOptions()"> Push Resize Items </mat-checkbox>
  <mat-form-field>
    <mat-label>Margin</mat-label>
    <input matInput [(ngModel)]="options.margin" min="0" max="30" step="1" type="number" (ngModelChange)="changedOptions()" />
  </mat-form-field>
  <mat-checkbox [(ngModel)]="options.outerMargin" (ngModelChange)="changedOptions()">Outer Margin </mat-checkbox>

  <mat-checkbox [(ngModel)]="options.useBodyForBreakpoint" (ngModelChange)="changedOptions()">Use Body Width as Breakpoint </mat-checkbox>
  <mat-form-field>
    <mat-label>Mobile Breakpoint</mat-label>
    <input matInput [(ngModel)]="options.mobileBreakpoint" type="number" (ngModelChange)="changedOptions()" />
  </mat-form-field>

  <mat-form-field>
    <mat-label>Fixed Col Width</mat-label>
    <input matInput [(ngModel)]="options.fixedColWidth" type="number" (ngModelChange)="changedOptions()" />
  </mat-form-field>
  <mat-form-field>
    <mat-label>Fixed Row Height</mat-label>
    <input matInput [(ngModel)]="options.fixedRowHeight" type="number" (ngModelChange)="changedOptions()" />
  </mat-form-field>
  <button mat-mini-fab (click)="addItem()" class="add-button cols-2">
    <mat-icon>add</mat-icon>
  </button>
</div>

<gridster [options]="options">
  @for (item of dashboard; track item.id) {
    <gridster-item [item]="item">
      <div class="button-holder">
        @if (item.hasContent) {
          <div class="gridster-item-content">
            <div class="stuff">
              <span>Some content to select and click without dragging the widget</span>
              <a href="https://www.google.com" target="_blank">Link to Google</a>
            </div>
          </div>
        }
        @if (item.hasContent) {
          <div class="item-buttons">
            <button class="drag-handler" mat-icon-button>
              <mat-icon>open_with</mat-icon>
            </button>
            <button mat-icon-button class="remove-button" (mousedown)="removeItem($event, item)" (touchstart)="removeItem($event, item)">
              <mat-icon>delete</mat-icon>
            </button>
          </div>
        }
        @if (!item.hasContent) {
          <label>{{ item.label }}</label>
        }
        @if (!item.hasContent) {
          <button mat-mini-fab (mousedown)="removeItem($event, item)" (touchstart)="removeItem($event, item)">
            <mat-icon>delete</mat-icon>
          </button>
        }
      </div>
    </gridster-item>
  }
</gridster>
